package com.ybt.heartratem.moudle.main;

import android.os.Bundle;
import android.text.TextUtils;

import androidx.lifecycle.ViewModelProviders;

import com.ybt.heartratem.R;
import com.ybt.heartratem.common.app.AppViewModelFactory;
import com.ybt.heartratem.common.app.Injection;
import com.ybt.heartratem.common.app.MyApplication;
import com.ybt.heartratem.databinding.ActivityBindDeviceBinding;
import com.ybt.heartratem.moudle.MainActivity;
import com.ybt.heartratem.moudle.MainVM;

import me.goldze.mvvmhabit.BR;
import me.goldze.mvvmhabit.base.BaseActivity;
import me.goldze.mvvmhabit.utils.ToastUtils;

/***
 * 绑定设备对应的学校ID-UI
 */
public class BindDeviceActivity extends BaseActivity<ActivityBindDeviceBinding, MainVM> {

    @Override
    public MainVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(MyApplication.getInstance());
        return ViewModelProviders.of(this, factory).get(MainVM.class);
    }

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_bind_device;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
        viewModel.getTeacherList();
        binding.bindDeviceTv.setOnClickListener(view -> {
            if (TextUtils.isEmpty(binding.bindSchoolIdEdt.getText().toString())) {
                ToastUtils.showLong("请输入绑定的学校ID");
                return;
            }else{
                viewModel.getSchoolData(Integer.parseInt(binding.bindSchoolIdEdt.getText().toString()));
            }
        });
    }
}